<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类式组件</title>
    <style>
        .header{
            height: 100px;
            background: #896;
        }
        .section{
            height: 300px;
            background: #c32;
        }
    </style>
</head>
<body>
    <div id="root"></div>

    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>

    <script type="text/babel">
        //1. 声明一个类
        class Header extends React.Component{
            render(){
                return <div className="header">我是一个类式组件-这里是头部区域</div>
            }
        }

        class Section extends React.Component{
            render(){
                let a = 100;
                let b = 200;
                console.log(a + b);
                return <div className="section" onClick={this.handle}>这里是内容区域</div>
            }
        }

        //2. 渲染
        //在 React 内部, 会对类进行实例化对象, 然后调用『实例对象』的render方法, 得到虚拟 DOM 对象, 将虚拟 DOM 对象转化为真实 DOM, 渲染到页面中.
        // ReactDOM.render(<Header></Header>, document.querySelector('#root'));
        // ReactDOM.render(<Header/>, document.querySelector('#root'));
        ReactDOM.render(<div>
                <Header />
                <Section />
            </div>, document.querySelector('#root'));


    </script>
</body>
</html>